package org.at.nhatky1;

import org.at.diary.NoteEdit;
import org.at.diary.NoteListView;
import org.at.diary.user.ChangePassword;
import org.at.diary.user.UpdateInfomation;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;

public class Overview extends Activity {
	
	ImageView imvWrite;
	ImageView imvRead;
	ImageView imvSetting;
	
	private static final int UPDATE_INFO = Menu.FIRST + 1;
	private static final int CHANGE_PASSWORD = Menu.FIRST + 2;
	
	private static final int UPDATE_INFO_REQUEST_CODE = 1;
	private static final int CHANGE_PASSWORD_REQUEST_CODE = 2;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		
		imvWrite = (ImageView) findViewById(R.id.imvWrite);
		imvWrite.setOnClickListener(new View.OnClickListener() {
			

			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent WriteDiaryIntent = new Intent(Overview.this, NoteEdit.class);
				startActivity(WriteDiaryIntent);
			}
		});
		imvRead = (ImageView) findViewById(R.id.imvRead);
		imvRead.setOnClickListener(new View.OnClickListener() {
			

			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent ReadDiaryIntent = new Intent(Overview.this, NoteListView.class);
				startActivity(ReadDiaryIntent);
			}
		});
	}
	
	public boolean onCreateOptionsMenu(Menu menu) {
		// TODO Auto-generated method stub
		MenuItem item_update_info = menu.add(Menu.NONE, UPDATE_INFO, Menu.NONE, R.string.update_info);
		item_update_info.setIcon(android.R.drawable.ic_menu_upload);
		MenuItem item_change_password = menu.add(Menu.NONE, CHANGE_PASSWORD, Menu.NONE, R.string.change_password);
		item_change_password.setIcon(R.drawable.change_password);
		return true;
	}
	
	public boolean onOptionsItemSelected(MenuItem item) {
		// TODO Auto-generated method stub
		switch (item.getItemId()) {
		case UPDATE_INFO:
			Intent updateInfoIntent = new Intent(this, UpdateInfomation.class);
			startActivityForResult(updateInfoIntent, UPDATE_INFO_REQUEST_CODE);
			return true;
		case CHANGE_PASSWORD:
			Intent changePasswordIntent = new Intent(Overview.this, ChangePassword.class);
			startActivityForResult(changePasswordIntent, CHANGE_PASSWORD_REQUEST_CODE);
			return true;
		default:
			return false;
		}
	}
}
